package com.greatwqs.wmall.common.module.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * 全局异常基类
 *
 * @author wang-qingsong
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class AppException extends RuntimeException {

    private ErrorCode errorCode;

    /**
     * 异常时传入的附加业务数据
     */
    private Object data;

    public AppException(ErrorCode errorCode) {
        super(errorCode.name());
        this.errorCode = errorCode;
    }

    public AppException(ErrorCode errorCode, Object data) {
        super(errorCode.name());
        this.errorCode = errorCode;
        this.data = data;
    }
}
